<?php namespace web\home\controller;
/** .-------------------------------------------------------------------
 * |  Software: [HDPHP framework]
 * |      Site: www.hdphp.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

class Orders extends Common {
	private $db;
	public function __construct(){
		parent::__construct();
		$this->db=new \system\model\Orders;
	}
	//首页
	public function index() {
		
		if(IS_POST){
//			p($_POST);die;
			$re=$this->db->store();
			if(!$re){
				message($this->db->getError(),'','error');die;
			}
//			注册成功提示
			message('订单提交成功',U('index'));
		}
	
		$data=Db::table('orders')->where('oid',$_SESSION['oid'])->first();
//		p($data);die;
//		p($_SESSION['shop']);
		View::with('data',$data);
		$listData=Db::table('orderlist')->join('goods','orderlist.gid','=','goods.gid')->join('goods_list','orderlist.glid','=','goods_list.glid')->where('oid',$_SESSION['oid'])->get();
		foreach ($listData as $k => $v) {
			$listData[$k]['combine']=explode('|',$v['combine']);
//			p($listData[$k]['combine']);
			foreach($listData[$k]['combine'] as $kk=>$vv){
				$listData[$k]['combine'][$kk]=Db::table('goods_attr')->where('gtid',$vv)->pluck('gtvalue');
			}
			$listData[$k]['combine']=implode('|',$listData[$k]['combine']);
		}
		
//		p($listData);die;
		View::with('listData',$listData);
		
		header("refresh:3;url=".U('home/user/user')."");
		
		View::make();
	}
}